from django.db import models
from django.contrib.auth.models import User

# Create your models here.
class Music(models.Model):
    name = models.CharField(max_length=50)
    singer = models.CharField(max_length=50)
    album = models.CharField(max_length=50)
    musiclink = models.CharField(max_length=300)
    adddate = models.DateTimeField(auto_now=True)
    addAnnoation = models.BooleanField()
    listencount = models.IntegerField(blank=True)

    def __unicode__(self):
        return self.name + "_" + self.singer

class MUser(models.Model):
    name = models.CharField(max_length=50)
    
class Annoation(models.Model):
    music = models.ForeignKey(Music)
    user = models.ForeignKey(User)
    pvalue = models.IntegerField()
    avalue = models.IntegerField()
    dvalue = models.IntegerField()
    ok = models.BooleanField()
    date = models.DateTimeField(auto_now=True)

    def __unicode__(self):
        return self.music.name + "_" + self.user.username
    
class Lyric(models.Model):
    music = models.ForeignKey(Music)
    lyric = models.TextField()

    def __unicode__(self):
        return self.music.name+"_"+self.music.singer
